<?php

namespace Shopadmin\Controller;
use Think\Controller;
class WechatController extends Controller
{
    public function weixin_chongzhi_notify()
    {
        $xml = file_get_contents("php://input");
        $data = xmlToArray($xml);
        $sign = $data['sign'];
        if ($sign) {
            //验证成功
            //获取微信的通知返回参数，可参考技术文档中服务器异步通知参数列表
            $result_code = $data['result_code'];
            $out_trade_no = $data['out_trade_no'];      //商户订单号
            $trade_no = $data['transaction_id'];          //微信订单号
            $total_fee = $data['total_fee'];         //交易金额
            $parameter = array(
                "out_trade_no" => $out_trade_no, //商户订单编号；
                "trade_no" => $trade_no, //支付宝交易号；
                "total_fee" => $total_fee, //交易金额；
                "trade_status" => $result_code, //交易状态
            );
            if ($result_code == 'SUCCESS') {
                update_chongzhi_order_weixin($parameter);

                echo "success";        //请不要修改或删除
            }else{
                echo "fail";
            }

        } else {
            //验证失败
            echo "fail";
        }
    }
}